<?php
// 本类由系统自动生成，仅供测试用途
class AskAction extends Action {
    /*
    *只是首页查看答案和问题页面
    *  */
    public function index(){
        $db=D('ContentView');
        import('Class.Category',APP_PATH);
        $cate=M('category')->order('sort ASC')->select();
        $this->cate=Category::unlimitedforlayer($cate);
        $this->you_qing_lian_jie_01=M('link')->order('id desc')->limit(0,12)->select();
        $this->you_qing_lian_jie_02=M('link')->order('id desc')->limit(12,12)->select();
        $this->ri_men=M('content')->order('count desc')->limit(13)->select();


        import('ORG.Util.Page');
        $count=M('message')->where(array('mes_replay'=>array('neq','')))->count();
        $page=new page($count,10);
        $limit=$page->firstRow.','.$page->listRows;
        $message = M('message')->where(array('mes_replay'=>array('neq','')))->order('id desc')->limit($limit)->select();
        $this->page=$page->show();
        $this->assign('message', $message)->display('massege');
    }
    /*
    *只是首页查看答案和问题方法
    *  */
    public function word(){
        if(!IS_POST) halt('页面不存在！');
        $data = array(
            'ask_content' => I('text'),
            'ask_ip' => get_client_ip(),
            'ask_time' => date('Y-m-d',time()),
        );

        if($data['ask_content'] != ""){
            if(M('message')->data($data)->add()){
                $this->success('添加成功');
            }else{
                $this->error('添加失败');
            }
        }
        else{
            $this->error('添加失败',U('index'));
        }
    }
}